//app.js
App({
	onLaunch: function(options) {
		console.log(options)
		var userid = options.query.userid?options.query.userid:false
		if(userid){
			wx.setStorage({
				key:"userid",
				data:userid
			})
		}
		
		// 判断是否是第一次进入,如果是将跳转到引导页,如果通过分享进入的话讲忽略这个页面
		var isFir = wx.getStorageSync("isFirst");
		if (!isFir) {
			wx.navigateTo({
				url: 'pages/guide/guide'
			})
		}
		
		// 获取openid
		wx.login({
			success: function(res) {
				var that = this
				var thiscode = res.code
				wx.request({
					url:"https://www.yoyuegoo.com/UUG/YApi/getOpenid",
					data:{code:thiscode},
					success:function(data){
						var thisopenid = data.data.obj
						// 将openid存进缓存
						wx.setStorage({
							key: 'openid',
							data: thisopenid,
						})
					}
				})
			}
		})
	},
	onShow: function () {
	},
	globalData: {
		userInfo: wx.getStorageSync("userinfo"),
		// 默认商城类型
		shoptype:0,
		shopstatr:false,
		// 检测是否登录
		haveYouLanded: function() {
			wx.getStorage({
				key: "administrator",
				success: function(data) {
					// 已登录,获取缓存
				},
				fail: function(res) {
					// 未登录,或者没有缓存 
				}
			})
		},
		login: function(username, password) {

		},
		// AdminUrl:"http://192.168.1.29",
		AdminUrl:"https://www.yoyuegoo.com/UUG/",
		sendMessage:function(phone){
			wx.request({
				url:"https://www.yoyuegoo.com/UUG//YApi/sendMessage",
				// url:"http://192.168.1.11/YApi/sendMessage",
				data:{
					phone:phone
				},
				success:function(data){
					var dataa = data.data.obj
					console.log(data)
				}
			})
		},
	},
})